package camel.first.api.datastore.internal.entity;

import javax.persistence.*;
import java.util.Collection;

/**
 * User: yuxinlei
 * Date: 4/13/11
 * Time: 1:51 PM
 */
@javax.persistence.Table(name = "promotions", catalog = "reportdb")
@Entity
public class PromotionsEntity {
    private int id;

    @javax.persistence.Column(name = "id", nullable = false, insertable = true, updatable = true, length = 10, precision = 0)
    @Id
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    private String name;

    @javax.persistence.Column(name = "name", nullable = true, insertable = true, updatable = true, length = 64, precision = 0)
    @Basic
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        PromotionsEntity that = (PromotionsEntity) o;

        if (id != that.id) return false;
        if (name != null ? !name.equals(that.name) : that.name != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        return result;
    }

    private Collection<PromotionBuildsEntity> promotionBuildsesById;

    @OneToMany(mappedBy = "promotionsByPromotionId")
    public Collection<PromotionBuildsEntity> getPromotionBuildsesById() {
        return promotionBuildsesById;
    }

    public void setPromotionBuildsesById(Collection<PromotionBuildsEntity> promotionBuildsesById) {
        this.promotionBuildsesById = promotionBuildsesById;
    }

    private ProjectsEntity projectsByProjectId;

    @ManyToOne
    public
    @JoinColumn(name = "project_id", referencedColumnName = "id")
    ProjectsEntity getProjectsByProjectId() {
        return projectsByProjectId;
    }

    public void setProjectsByProjectId(ProjectsEntity projectsByProjectId) {
        this.projectsByProjectId = projectsByProjectId;
    }
}
